<template>
	<scroll-view scroll-y class="public-scroll-view">
		<view class="set-time-out">
			<button type="primary" @click="onSetTimeout">单次定时器</button>
			<button type="primary" plain="true" @click="onSetTimeout('lyq',888)">启动动传参定时器</button>
			<button type="warn" @click="onClearTimeout">取消定时器</button>
		</view>
	</scroll-view>
</template>

<script>
	export default {
		data() {
			return {
				timer: null
			}
		},
		methods: {
			onSetTimeout() {
				console.log("单次定时器");
				this.timer = setTimeout(() => {
					console.log("单次定时器3秒");
				}, 3000)
				console.log("单次定时器");
			},
			// onSetTimeout(name,number){
			// 	console.log("传参单次定时器");
			// 	setTimeout((x,y)=>{
			// 		console.log("传参单次定时器"+x+y);
			// 	},3000,name,number)
			// }
			onClearTimeout() {
				console.log("取消单次定时器");
				clearTimeout(this.timer);
			}
		}
	}
</script>

<style>
	.set-time-out {
		padding-top: 30rpx;
	}

	.set-time-out>button {
		margin-top: 20rpx;
		width: 90%;
	}
</style>